﻿@model SuperiorModel.Api_CouponManagerModel
@{
    ViewBag.Title = "优惠券中心";
    Layout = "~/Views/Shared/_Layout.cshtml";
    var spid = Request["spid"];
    var said = Request["said"];
}
<style>
    .couponDiv{
  width:350px;
margin:0 auto;
margin-top:9.5px;

}
.couponItem{
  width: 100%;
  height: 100px;
 
}
.couponTest{
  font-size:12px;
padding:2.5px 7.5px;
color:white;
text-align:center;


}
.stamp{width:350px; height: 140px;margin-bottom:25px;position:relative;overflow:hidden}
.stamp_my{width:350px; height: 79px;margin-bottom:25px;position:relative;overflow:hidden}
.stamp i{position: absolute;left: 20%;top: 45px;height: 250px;width: 350px;background-color: rgba(255,255,255,.15);transform: rotate(-30deg);
}

.stamp02{background:radial-gradient(rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0) 30rpx, #D24161 30rpx);background-size:5px 5px;background-position:4.5px 1.5px; background: #D24161}
.stamp03{background:radial-gradient(rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0) 30rpx, #D24161 30rpx);background-size:5px 5px;background-position:4.5px 1.5px; background: #7EAB1E }

</style>
<header class="wy-header" style="position:fixed; top:0; left:0; right:0; z-index:200;">
    <div class="wy-header-icon-back"><a href="javascript:history.go(-1)"><span></span></a></div>
    <div class="wy-header-title">优惠券</div>
</header>
<div class='weui-content'>
    <div class="weui-tab">
        <div class="weui-navbar" style="position:fixed; top:44px; left:0; right:0; height:44px; background:#fff;">
            <a class="weui-navbar__item proinfo-tab-tit font-14 weui-bar__item--on" href="#tab1">商户优惠券</a>
            <a class="weui-navbar__item proinfo-tab-tit font-14" href="#tab2">我的优惠券</a>
          
        </div>
        <div class="weui-tab__bd proinfo-tab-con" style="padding-top:61px;">
            <div id="tab1" class="weui-tab__bd-item weui-tab__bd-item--active">
                <div class="couponDiv">
                    @foreach (var item in Model.Coupons)
                    {
                        <div class='couponItem stamp @(item.CouponType==1?"stamp02":"stamp03")'>
                            <div class="couponTest">@item.CouponName</div>
                            @if (item.CouponType == 1)
                            {
                                <div class="couponTest" >满@(item.MinOrderAmount)减@(item.DelAmount)</div>
                            }
                            else if (item.CouponType == 2)
                            {
                                <div class="couponTest">@(item.Discount/10)折</div>
                            }

                           
                            <div class="couponTest">有效天数:@item.Days</div>
                            <div class="couponTest">剩余数量:@(item.TotalCount)张</div>
                            <a style="background-color: steelblue;" href="javascript:;" class="weui-btn weui-btn weui-btn_primary getCoupon" couponId="@item.Id">立即领取</a>
                        </div>
                    }
                </div>
              
                

            </div>
            <div id="tab2" class="weui-tab__bd-item">

                <div class="couponDiv">
                    @foreach (var item in Model.MyCoupons)
                    {

                        <div class='couponItem stamp_my @(item.CouponType==1?"stamp02":"stamp03") '>
                            <div class="couponTest">@item.CouponName</div>
                            @if (item.CouponType == 1)
                            {
                                <div class="couponTest">满@(item.MinOrderAmount)减@(item.DelAmount)</div>
                            }
                            else if (item.CouponType == 2)
                            {
                                <div class="couponTest">@(item.Discount / 10)折</div>
                            }
                            <div class="couponTest">有效期至:@item.ExpressTime</div>
                        </div>
                    }

           
      
        </div>
    </div>
</div>

<script>
    var spid = ToolManager.Common.UrlParms("spid");
    $(document).on('click', '.getCoupon', function () {
        var couponId = $(this).attr("couponId");
        $.get("/User/GetCoupon?couponid=" + couponId + "&spid="+spid+"&r=" + new Date().getTime(), function (data) {
            if (data.IsSuccess) {
                layer.msg("领取成功", function () {
                    window.location.reload();
                })
            } else {
                layer.msg(data.Message);
            }
        })
    })
</script>